<?php

namespace Home\Controller;
use Think\Upload\Driver\Qiniu\QiniuStorage;
use Think\AjaxPage;
use Think\Page;
class FamilyController extends BaseController {
    
    /**
     * 初始化函数
    */
    public function _initialize() {
        parent::_initialize();
        $this->user = session('admin_id');
        $this->pid  = session('pid');
    }
    
    /**
     * 族列表
     */
    public function library(){
        $uid = $this->user;
        $ppdata = M('process')->field('launch')->where(array('type'=>2,'pid'=>0))->find();
        if(empty($ppdata['launch'])){
            $pdata = 1;
            $this->assign('pdata',$pdata);
        }else{
            $pdata = explode(',',$ppdata['launch']);
            if(in_array($uid,$pdata)){
                $pdata = 2;
                $this->assign('pdata',$pdata);
            }
        }
        $category = M('category')->select();
        foreach ($category as $key=>$val){
            if($val['leve']==1){
                $cate['type'][] = $val;
            }
            if($val['leve']==2){
                $cate['series'][] = $val;
            }
            if($val['leve']==3){
                $cate['file_type'][] = $val;
            }
            if($val['leve']==4){
                $cate['brand'][] = $val;
            }
        }
        $this->assign('cate',$cate);
        $this->display();
    }
    
    /**
     * ajax族列表
     */
    public function ajaxlibrary(){
        $Modal = M('library');
        $search = I('post.name');
        $status = I('post.status');
        $type = I('post.type');
        if($type){
            if($status==1){
                $where[] = "type='".addslashes($type)."'";
            }
            if($status==2){
                $where[] = "series='".addslashes($type)."'";
            }
            if($status==3){
                $where[] = "file_type='".addslashes($type)."'";
            }
            if($status==4){
                $where[] = "brand='".addslashes($type)."'";
            }
        }
        if($search){
            $where[] = "name like '%$search%' ";
        }
        $where = implode(' AND ', $where);
        $count = $Modal->where($where)->count();
        $Page  = new AjaxPage($count,20);
        //  搜索条件下 分页赋值
        foreach($where as $key=>$val) {
            $Page->parameter[$key]   =   urlencode($val);
        }
        $List = $Modal->field('status,name,id,image,uid')->where($where)->order("id desc")->limit($Page->firstRow.','.$Page->listRows)->select();
        $show = $Page->show();
        $status = array('1'=>'校对中……','2'=>'审核中……','3'=>'查看详情','4'=>'校对驳回……','5'=>'审核驳回……');
        $role['role'] = session('role');
        $role['aid'] = session('admin_id');
        
        $this->assign('role',$role);
        $this->assign('status',$status);
        $this->assign('data',$List);
        $this->assign('page',$show);
        $this->display();
    }
    
    /**
     * 审核状态页
     */
    public function shenh(){
        $id = I('get.id');
        if(!$id){
            $this->error('id获取失败');
        }
        $data = M('library')->where('id='.$id)->find();
        if($data['status']==1 || $data['status']==4){
           $eid = M('process_data')->field('examine_id')->where('eid=5')->find();
           if($eid){
               $name = M('admin')->field('name')->where('admin_id='.$eid['examine_id'])->find();
           }
        }
        if($data['status']==2 || $data['status']==5){
            $eid = M('process_data')->field('examine_id')->where('eid=6')->find();
            if($eid){
                $name = M('admin')->field('name')->where('admin_id='.$eid['examine_id'])->find();
            }
        }
        if($name){
            $this->assign('name',$name['name']);
        }
        
        $Modal = M('opinion');
        if($data['status']==4){
            $design = $Modal->field('design')->where(array('oid'=>$data['id'],'status'=>6))->order('id desc')->find();
            $data['design'] = $design['design'];
        }
        if($data['status']==5){
            $design = $Modal->field('design')->where(array('oid'=>$data['id'],'status'=>8))->order('id desc')->find();
            $data['design'] = $design['design'];
        }
        
        $brand = M('category')->field('name')->where(array('id'=>$data['brand']))->find();
        $data['brand'] = $brand['name'];
        $status = array('1'=>'校对中……','2'=>'审核中……','4'=>'校对驳回','5'=>'审核驳回');
        $this->assign('status',$status);
        $this->assign('data',$data);
        $this->display();
    }
    
    /**
     * 添加产品
     */
    public function libraryadd(){
        $Mode = M('library');
        if(IS_POST){
            $files = $_FILES;
            if($files['image']['size']>1*1024*1024){
                $this->error('图片过大,图片请在在1M以下');
            }
            if($files['file']['size']>5*1024*1024){
                $this->error('文件过大,文件请在在5M以下');
            }
            if($files['image']['name'] != '' && $files['file']['name'] != ''){
                $img = $this->oimg($_FILES);
                if($img){
                    $data = I('post.');
                    $data['describe'] = json_encode($data['describe']);
                    $data['text'] = json_encode($data['text']);
                    $data['image'] = $img[0];
                    $data['file'] = $img[1];
                    $data['filename'] = $files['file']['name'];
                    $data['add_time'] = time();
                    $data['status'] = 1;
                    $data['explain'] = 1;
                    if($data['id']){
                        $f = $Mode->field('image,file')->where('id='.$data['id'])->find();
                        //删除原文件
                        if($f){
                            $setting = C('UPLOAD_PUBLIC_QINIU');
                            $Qiniu = new QiniuStorage($setting['driverConfig']);
                            if($f['file']){
                                $path = parse_url($f['file']);
                                $file_name = str_replace('/','',$path['path']);
                                $Qiniu->del($file_name);
                            }
                            if($f['image']){
                                $pat = parse_url($f['image']);
                                $file_nam = str_replace('/','',$pat['path']);
                                $Qiniu->del($file_nam);
                            } 
                        }
                        
                        $ress = $Mode->where('id='.$data['id'])->save($data);
                        if($ress){
                            $res = $data['id'];
                        }
                    }else{
                        $uid = $this->user;
                        $data['uid'] = $uid;
                        $res = $Mode->add($data);
                    }
                    if($res){
                        $this->ftask($res,1,$data['name']);
                        adminLog("族库产品".$data['name']."正在校对中",__ACTION__);
                        $this->success('提交成功',U('Family/library'));exit;
                    }else{
                        $this->error('提交失败');
                    }
                }
            }
        }
        $Modal = M('process_data');
        $xao = $Modal->field('examine_id')->where(array('pid'=>0,'typeid'=>2,'eid'=>5))->find(); 
        if(empty($xao['examine_id'])){
            $this->error('校对人未设置');
        }
        $s = $Modal->field('examine_id')->where(array('pid'=>0,'typeid'=>2,'eid'=>6))->find();
        if(empty($s['examine_id'])){
            $this->error('审核人未设置');
        }
        
        $category = M('category')->select();
        foreach ($category as $key=>$val){
            if($val['leve']==1){
                $cate['type'][] = $val;
            }
            if($val['leve']==2){
                $cate['series'][] = $val;
            }
            if($val['leve']==3){
                $cate['file_type'][] = $val;
            }
            if($val['leve']==4){
                $cate['brand'][] = $val;
            }
        }
        $id = I('get.id');
        if($id){
            $data= $Mode->where('id='.$id)->find();
            if($data){
                $this->assign('data',$data);
            }
        }
        $this->assign('cate',$cate);
        $this->display();
    }
    
    /**
     * 发送任务和站内信
     */
    public function ftask($id,$status,$name){
        if($status==1){
            $eid = 5;
            $se = '校对';
            $an = 'school';
        }else{
            $eid = 6;
            $se = '审核';
            $an = 'review';
        }
         $tid = M('process_data')->field('examine_id')->where('eid='.$eid)->find();
         $a['pid'] = 0;
         $a['type'] = 3;
         $a['priority'] = 1;
         $a['severity'] = 0;
         $a['t_stop'] = date("Y-m-d H:i:s",strtotime("+1 day"));
         $a['add_time'] = time();
         $a['status'] = 8;
         $a['assigname'] = '自己(我)';
         $a['cfrom'] = session('admin')['name'];
         $a['link'] = $id .','. $an;
         $a['assign'] = $tid['examine_id'];
         $a['describe'] = '族库产品'.$name.$se;
         $a['name'] = '产品'.$name.$se;
         $d = task($a);
        taskLog("下发了".$name."产品".$se,$d);
        $pname = session('pname');
        $s[] = $tid['examine_id'];
        SendMessage($s,'族库产品'.$se,'你有'.$se.'任务,产品名为'.$name.'请到项目管理-任务状态-待我审查的任务中查看');
    }
    
    /**
    * 上传编制图片或文件
    */
    public function oimg($file){
        $setting = C('UPLOAD_PUBLIC_QINIU');
        $Upload = new \Think\Upload($setting);
        $info = $Upload->upload($file);
        if(!$info){
            $this->error('上传失败请重试');
        }
       // $path = str_replace('/','_',$info['image']['savepath']);
        $a[0] = $info['image']['url'];//七牛云保存的文件名称
        //$path = str_replace('/','_',$info['file']['savepath']);
        $a[1] = $info['file']['url'];//七牛云保存的文件名称
        if($a[0] !='' && $a[1]!=''){
            return $a;
        }else{
            $this->error('上传失败了请重试');
        }
    }
    
    /**
     * 校对审核
     */
    public function school(){
        $id = I('get.id');
        $tid = I('get.tid');
        if(!$id || !$tid){
            $this->error('id出现未知错误,请重试');
        }
        
        $Modal = M('opinion');
        $data = M('library')->where('id='.$id)->find(); 
        $status = array('1'=>'校对中……','2'=>'审核中……','4'=>'校对驳回','5'=>'审核驳回','3'=>'完成');
        $data['tid'] = $tid;
        
        if($data['status']==2){
            $design = $Modal->field('design')->where(array('oid'=>$data['id'],'status'=>5))->order('id desc')->find();
            $data['design'] = $design['design'];
        }
        if($data['status']==4){
            $design = $Modal->field('design')->where(array('oid'=>$data['id'],'status'=>6))->order('id desc')->find();
            $data['design'] = $design['design'];
        }
        $brand = M('category')->field('name')->where(array('id'=>$data['brand']))->find();
        $data['brand'] = $brand['name'];
        $this->assign('status',$status);
        $this->assign('data',$data);
        $this->display();
    }
    
    /**
     * 校对通过或驳回
     */
    public function school_judge(){
        $data = I('post.');
        if(!$data['id'] || !$data['tid']){
            exit(json_encode(array('errNo'=>1,'msg'=>'id数据有误')));
        }
        
        $Mo = M('library');
        $Modal = M('opinion');
        $uid = session('admin_id');
        $time = time();
        //通过为1
        if($data['status']==1){
            $res = $Modal->where(array('oid'=>$data['id'],'uid'=>$uid,'status'=>5))->count();
            if($res){
                $Modal->where(array('oid'=>$data['id'],'uid'=>$uid,'status'=>5))->save(array('design'=>$data['design']));
            }else{
                $ad['oid'] = $data['id'];
                $ad['uid'] = $uid;
                $ad['status'] = 5;
                $ad['design'] = $data['design'];
                $ad['add_time'] = time();
                $Modal->add($ad);
            }
            $r =  $Mo->where('id='.$data['id'])->save(array('status'=>2));
            if($r){
                adminLog('校对通过了'.$data['name'].'产品',__ACTION__);
                $this->ftask($data['id'],2,$data['name']);
                M('task')->where('tid='.$data['tid'])->save(array('status'=>4,'time_stop'=>$time));
                exit(json_encode(array('errNo'=>0,'msg'=>'通过成功')));
            }else{
                exit(json_encode(array('errNo'=>1,'msg'=>'通过失败,请重试')));
            }
        }
        if($data['status']==2){
            $res = $Modal->where(array('oid'=>$data['id'],'uid'=>$uid,'status'=>6))->count();
            if($res){
                $Modal->where(array('oid'=>$data['id'],'uid'=>$uid,'status'=>6))->save(array('design'=>$data['design']));
            }else{
                $ad['oid'] = $data['id'];
                $ad['uid'] = $uid;
                $ad['status'] = 6;
                $ad['design'] = $data['design'];
                $ad['add_time'] = time();
                $Modal->add($ad);
            }
            $r =  $Mo->where('id='.$data['id'])->save(array('status'=>4));
            if($r){
                adminLog('校对驳回了'.$data['name'].'产品',__ACTION__);
                M('task')->where('tid='.$data['tid'])->save(array('status'=>4,'time_stop'=>$time));
                $rr =  $Mo->field('uid,image,name,file')->where('id='.$data['id'])->find();
                $s[] = $rr['uid'];
                SendMessage($s,'族库产品'.$rr['name'].'在校对中被驳回','你的族库产品'.$rr['name'].'在校对中被驳回,请到族库管理-族库列表中查看');
                exit(json_encode(array('errNo'=>0,'msg'=>'驳回成功')));
            }else{
                exit(json_encode(array('errNo'=>1,'msg'=>'驳回失败,请重试')));
            }
        }
    }
    
    /**
     * 产品审核
     */
    public function review(){
        $id = I('get.id');
        $tid = I('get.tid');
        if(!$id || !$tid){
            $this->error('id出现未知错误,请重试');
        }
        
        $Modal = M('opinion');
        $data = M('library')->where('id='.$id)->find(); 
        $status = array('1'=>'校对中……','2'=>'审核中……','4'=>'校对驳回','5'=>'审核驳回','3'=>'完成');
        $data['tid'] = $tid;
        
        if($data['status']==3){
            $design = $Modal->field('design')->where(array('oid'=>$data['id'],'status'=>7))->order('id desc')->find();
            $data['design'] = $design['design'];
        }
        if($data['status']==5){
            $design = $Modal->field('design')->where(array('oid'=>$data['id'],'status'=>8))->order('id desc')->find();
            $data['design'] = $design['design'];
        }
        //校对意见
        $desig = $Modal->field('design')->where(array('oid'=>$data['id'],'status'=>5))->order('id desc')->find();
        $data['desig'] = $desig['design'];
        //查询品牌
        $brand = M('category')->field('name')->where(array('id'=>$data['brand']))->find();
        $data['brand'] = $brand['name'];
        
        $this->assign('status',$status);
        $this->assign('data',$data);
        $this->display();
    }
    
    /**
     * 产品审核通过或驳回
     */
    public function review_judge(){
        $data = I('post.');
        if(!$data['id'] || !$data['tid']){
            exit(json_encode(array('errNo'=>1,'msg'=>'id数据有误')));
        }
    
        $Mo = M('library');
        $Modal = M('opinion');
        $uid = session('admin_id');
        $time = time();
        //通过为1
        if($data['status']==1){
            $res = $Modal->where(array('oid'=>$data['id'],'uid'=>$uid,'status'=>7))->count();
            if($res){
                $Modal->where(array('oid'=>$data['id'],'uid'=>$uid,'status'=>7))->save(array('design'=>$data['design']));
            }else{
                $ad['oid'] = $data['id'];
                $ad['uid'] = $uid;
                $ad['status'] = 7;
                $ad['design'] = $data['design'];
                $ad['add_time'] = time();
                $Modal->add($ad);
            }
            $r =  $Mo->where('id='.$data['id'])->save(array('status'=>3));
            if($r){
                adminLog('审核通过了'.$data['name'].'产品',__ACTION__);
                M('task')->where('tid='.$data['tid'])->save(array('status'=>4,'time_stop'=>$time));
                exit(json_encode(array('errNo'=>0,'msg'=>'通过成功')));
            }else{
                exit(json_encode(array('errNo'=>1,'msg'=>'通过失败,请重试')));
            }
        }
        if($data['status']==2){
            $res = $Modal->where(array('oid'=>$data['id'],'uid'=>$uid,'status'=>8))->count();
            if($res){
                $Modal->where(array('oid'=>$data['id'],'uid'=>$uid,'status'=>8))->save(array('design'=>$data['design']));
            }else{
                $ad['oid'] = $data['id'];
                $ad['uid'] = $uid;
                $ad['status'] = 8;
                $ad['design'] = $data['design'];
                $ad['add_time'] = time();
                $Modal->add($ad);
            }
            $r =  $Mo->where('id='.$data['id'])->save(array('status'=>5));
            if($r){
                adminLog('审核驳回了'.$data['name'].'产品',__ACTION__);
                M('task')->where('tid='.$data['tid'])->save(array('status'=>4,'time_stop'=>$time));
                $rr =  $Mo->field('uid,image,name,file')->where('id='.$data['id'])->find();
                $s[] = $rr['uid'];
                SendMessage($s,'族库产品'.$rr['name'].'审核中被驳回','你的族库产品'.$rr['name'].'在审核中被驳回,请到族库管理-族库列表中查看');
                exit(json_encode(array('errNo'=>0,'msg'=>'驳回成功')));
            }else{
                exit(json_encode(array('errNo'=>1,'msg'=>'驳回失败,请重试')));
            }
        }
    }
    
    /**
     * 产品详情
     */
    public function detail(){
        $id = I('get.id');
        if(!$id){
            $this->error('id有误');
        }
        $data = M('library')->where('id='.$id)->find();
        $brand = M('category')->where(array('id'=>$data['brand']))->find();
        $data['brand'] = $brand['name'];
        $this->assign('data',$data);
        $this->display();
    }
    
    /**
     * 产品详情打印
     */
    public function libraryprint(){
        $id = I('get.id');
        if(!$id){
            $this->error('id有误');
        }
        $data = M('library')->where('id='.$id)->find();
        $this->assign('data',$data);
        $this->display();
    }
    
    /**
     * 品牌
     */
    public function brand(){
        if(IS_POST){
            $data['name'] = I('post.name');
            if($data['name']==''){
                exit(json_encode(array('errNo'=>1,'msg'=>'品牌名称不能为空')));
            }
        }
        $this->display();
    }
    
    /**
     * ajax品牌
     */
    public function ajaxbrand(){
                // 搜索条件
        $name = I('post.name');
        $Model = M('category');
        $where=array();
        $where[] = "leve = 4";
        if($name){
            $where[] = "name like '%$name%' ";
        }
        
        $where = implode(' AND ', $where);
        $count =  $Model->where($where)->count();
        $Page  = new AjaxPage($count,10);
        //  搜索条件下 分页赋值
        foreach($condition as $key=>$val) {
            $Page->parameter[$key]   =   urlencode($val);
        }
       
        $data = $Model->where($where)->limit($Page->firstRow.','.$Page->listRows)
                ->order('id desc')
                ->select();
        $show = $Page->show();
        $this->assign('data',$data);
        $this->assign('page',$show);// 赋值分页输出
        $this->display();
    }
    
    /**
     * 新增或编辑品牌
     */
    public function aebrand(){
        $act = I('post.act');
        $name = I('post.name');
        $id = I('post.id');
        $Model = M('category');
        if($name==''){
            exit(json_encode(array('errNo'=>1,'msg'=>'品牌名称不能为空')));
        }
        if($act=='add'){
            $co = $Model->where(array('name'=>$name))->count();
            if($co){
                exit(json_encode(array('errNo'=>1,'msg'=>'品牌名称已存在')));
            }
            $data['name'] = $name;
            $data['leve'] = 4;
            $data['add_time'] = time();
            $res = $Model->add($data);
        }
        if($act=='edit' && $id!=''){
            $res = $Model->where('id='.$id)->save(array('name'=>$name));
        }
        if($res){
            exit(json_encode(array('errNo'=>0,'msg'=>'操作成功')));
        }else{
            exit(json_encode(array('errNo'=>1,'msg'=>'操作失败')));
        }
    }
    
    /**
     * 编辑产品
     */
    public function editlibrary(){
        $id = I('get.id');
        $Modal = M('library');
        if(IS_POST){
            $res = I('post.');
            if(!$res['id']){
                $this->error('id未接收到');
            }
            $file = $_FILES;
            if($file['image']['name']!='' || $file['file']['name']!=''){
                if($files['image']['size']>1*1024*1024){
                    $this->error('图片过大,图片请在在1M以下');
                }
                if($files['file']['size']>5*1024*1024){
                    $this->error('文件过大,文件请在在5M以下');
                }
                if($file['image']['name']=='' && $file['file']['name']!=''){
                    unset($file['image']);
                }
                if($file['image']['name']!='' && $file['file']['name']==''){
                    unset($file['file']);
                }
                $setting = C('UPLOAD_PUBLIC_QINIU');
                $Upload = new \Think\Upload($setting);
                $info = $Upload->upload($file);
                if(!$info){
                    $this->error('上传失败请重试');
                }
                $a[0] = $info['image']['url'];//七牛云保存的文件名称
                $a[1] = $info['file']['url'];//七牛云保存的文件名称
                if($a[0]!='' && $a[0]!=null){
                    $res['image'] = $a[0];
                }
                if($a[1]!='' && $a[1]!=null){
                    $res['file'] = $a[1];
                    $res['filename'] = $file['file']['name'];
                }
            }
            $res['text'] = json_encode($res['text']);
            $res['describe'] = json_encode($res['describe']);
            $res['explain'] = json_encode($res['explain']);
            $res['status'] = 1;
            $da = $Modal->where(array('id'=>$res['id']))->save($res);
            if($da){
                $this->ftask($res['id'],1,$res['name']);
                adminLog("族库产品".$res['name']."正在校对中",__ACTION__);
                $this->success('更新成功',U('Family/library'));exit;
            }else{
                $this->error('更新失败,请重试');
            }
        }
        if(!$id){
            $this->error('id不存在');
        }
        $Mo = M('process_data');
        $xao = $Mo->field('examine_id')->where(array('pid'=>0,'typeid'=>2,'eid'=>5))->find();
        if(empty($xao['examine_id'])){
            $this->error('校对人未设置');
        }
        $s = $Mo->field('examine_id')->where(array('pid'=>0,'typeid'=>2,'eid'=>6))->find();
        if(empty($s['examine_id'])){
            $this->error('审核人未设置');
        }
        
        $data = $Modal->where(array('id'=>$id))->find();
        $category = M('category')->select();
        foreach ($category as $key=>$val){
            if($val['leve']==1){
                $cate['type'][] = $val;
            }
            if($val['leve']==2){
                $cate['series'][] = $val;
            }
            if($val['leve']==3){
                $cate['file_type'][] = $val;
            }
            if($val['leve']==4){
                $cate['brand'][] = $val;
            }
        }
        
        $this->assign('cate',$cate);
        $this->assign('data',$data);
        $this->display();
    }
    
    
    /**
     * 删除品牌
     */
    public function del(){
        $id = I('post.id');
        if(!$id){
            exit(json_encode(array('errNo'=>1,'msg'=>'ID有误')));
        }
        $res = M('category')->where('id='.$id)->delete();
        if($res){
            exit(json_encode(array('errNo'=>0,'msg'=>'删除成功')));
        }else{
            exit(json_encode(array('errNo'=>1,'msg'=>'删除失败')));
        }
    }
    
    
    public function upload(){
        $info = array(
            'num'=> 1,
            'title' => '上传文件',
            'upload' =>U('/Family/fileup'),
            'size' => '2M',
            'type' =>'jpg,png,gif,jpeg,xls,xlsx',
            'input' => 'imagetext',
            'func' => empty($func) ? 'undefined' : $func,
        );
        $this->assign('info',$info);
        $this->display();
        
        
      /*   echo "<script>parent.call_back(1);</script>";
        exit(); */
           /*  $upload = new \Think\Upload();// 实例化上传类
            $upload->maxSize   =     3145728 ;// 设置附件上传大小
            $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
            $upload->rootPath  =     './Uploads/'; // 设置附件上传根目录
            $upload->savePath  =     ''; // 设置附件上传（子）目录
            // 上传文件
            $info   =   $upload->upload();
              if(!$info)
              {
                 $data = ['msg'=>'上传失败，'.$Upload->getError()];
               //  echo "<script>alert('{$data}')</script>";
               $this->error('上传失败'.$Upload->getError());
              }
              else
              { 
                   $data['path'] = $info['fileToUpload']['savepath'];
                   $data['name'] =  $info['fileToUpload']['savename'];
                   $data = json_encode($data);
                   echo "<script>parent.call_back(1,{$data});</script>";
                   exit(); 
              }  */
    }
    
    /**
     * 上传文件
     */
    public function fileup(){
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize   =     3145728 ;// 设置附件上传大小
        $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg','xls');// 设置附件上传类型
        $upload->rootPath  =     './Uploads/'; // 设置附件上传根目录
        $upload->savePath  =     ''; // 设置附件上传（子）目录
        // 上传文件
        $info   =   $upload->upload();
          if(!$info)
          {
           //  $data = $upload->getError();
            // echo "<script>alert('{$data}')</script>";
             $return_data['state'] = 'error';
             $return_data['text'] = $upload->getError();
             $this->ajaxReturn($return_data,'json');
          }
          else
          { 
               $return_data['url'] = '/uploads/'.$info['Filedata']['savepath'].$info['Filedata']['savename'];
               $return_data['title'] = '文件上传';
               $return_data['original'] = $info['Filedata']['name'];
               $return_data['state'] = 'SUCCESS';
               $this->ajaxReturn($return_data,'json');
          }  
    }
}